﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aplicacao;
using System.Net.Mail;

public partial class fale_conosco : System.Web.UI.Page
{
    Validate va;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            va = new Validate();
            Page.Validate("FaleConosco");
            if (Page.IsValid)
                EnviaFaleConosco();
        }

    }

    private void EnviaFaleConosco() {
        MailMessage ma = new MailMessage(new MailAddress("felipe.alvescoutinho@gmail.com"), new MailAddress("felipecoutinho00@gmail.com"));
        ma.Body = "<html><head></head><body>Teste de envio fale conosco</body></html>";
        ma.IsBodyHtml = true;

        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com.br";
        smtp.EnableSsl = true;
        try
        {
            smtp.Send(ma);
        }
        catch(Exception ex){
            ErrorServer.InnerText = ex.Message;
            ErrorServer.Visible = true;
        }
    }

    public void ValidateEmail(object source, ServerValidateEventArgs args)
    {
        args.IsValid = va.ValidarEmail(fieldEmail);
    }
}